package com.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.entity.StudentInfo;
import com.service.StudentInfoService;

/**
 * Servlet implementation class UPdate
 */
public class UPdate extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		int id=Integer.parseInt(request.getParameter("id"));
		String name=request.getParameter("name");
		String sex=request.getParameter("sex");
		int age=Integer.parseInt(request.getParameter("age")) ;
		String address=request.getParameter("address");
		String email=request.getParameter("email");
		StudentInfo studentInfo=new StudentInfo();
		studentInfo.setSid(id);
		studentInfo.setSaddress(address);
		studentInfo.setSage(age);
		studentInfo.setSemail(email);
		studentInfo.setSgender(sex);
		studentInfo.setSname(name);
		StudentInfoService service=new StudentInfoService();
		int result=service.Upda(studentInfo);
		
		
		request.setAttribute("result", result);
		request.getRequestDispatcher("List").forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
